<!DOCTYPE html>
<html >
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>多维数组遍历</title>
    <script>
        let arr1 = [5,[4,6,7],[[1,2,5],16],3,8,12];
        let arr2 = [[[1,2,3],[4,5,6]],[[7,8,9],[10,11,12]],[[13,14,15],[16,17,18]]];
        function fn(arr){
            for(let i=0;i<arr.length;i++){
                if(typeof arr[i]==="object"){
                    fn(arr[i]);
                }else{
                    console.log(arr[i]);
                }
            }
        }
        fn(arr1);
        fn(arr2);
    </script>
</head>
<body>
    
</body>
</html>